Imports Microsoft.VisualBasic

Namespace effority.UserDirectory

    Public Class DataProviderInformation

#Region " Private Members "

        Private Const ProviderType As String = "data"

        Private Shared _providerConfiguration As DotNetNuke.Framework.Providers.ProviderConfiguration = DotNetNuke.Framework.Providers.ProviderConfiguration.GetProviderConfiguration(ProviderType)
        Private Shared _connectionString As String
        Private Shared _providerPath As String
        Private Shared _objectQualifier As String
        Private Shared _databaseOwner As String

#End Region

#Region " Methods "

        Private Shared Sub Load()

            ' Read the configuration specific information for this provider
            Dim objProvider As DotNetNuke.Framework.Providers.Provider = CType(_providerConfiguration.Providers(_providerConfiguration.DefaultProvider), DotNetNuke.Framework.Providers.Provider)

            ' Read the attributes for this provider
            _connectionString = DotNetNuke.Common.Utilities.Config.GetConnectionString()

            _providerPath = objProvider.Attributes("providerPath")

            _objectQualifier = objProvider.Attributes("objectQualifier")
            If _objectQualifier <> "" And _objectQualifier.EndsWith("_") = False Then
                _objectQualifier += "_"
            End If

            _databaseOwner = objProvider.Attributes("databaseOwner")
            If _databaseOwner <> "" And _databaseOwner.EndsWith(".") = False Then
                _databaseOwner += "."
            End If

        End Sub

#End Region

#Region " Properties "

        Public Shared ReadOnly Property ConnectionString() As String
            Get
                If String.IsNullOrEmpty(_connectionString) Then
                    Load()
                End If

                Return _connectionString
            End Get
        End Property

        Public Shared ReadOnly Property ProviderPath() As String
            Get
                If String.IsNullOrEmpty(_providerPath) Then
                    Load()
                End If

                Return _providerPath
            End Get
        End Property

        Public Shared ReadOnly Property ObjectQualifier() As String
            Get
                If String.IsNullOrEmpty(_objectQualifier) Then
                    Load()
                End If

                Return _objectQualifier
            End Get
        End Property

        Public Shared ReadOnly Property DatabaseOwner() As String
            Get
                If String.IsNullOrEmpty(_databaseOwner) Then
                    Load()
                End If

                Return _databaseOwner
            End Get
        End Property

#End Region

    End Class

End Namespace
